import 'package:flutter/material.dart';
import 'package:xindong/common/xindong_sezhi.dart';
import 'package:xindong/common/xindong_define.dart';
import 'package:xindong/manager/xindong_page_singleton.dart';
import 'package:xindong/routes/tab_moments/details/xindong_dongtai_details_yemian.dart';
import 'package:xindong/routes/tab_moments/model/xindong_dongtai_class.dart';
import 'package:xindong/routes/tab_moments/view/xindong_dongtai_list_view_cell_footer.dart';
import 'package:xindong/routes/tab_moments/view/xindong_dongtai_list_view_cell_header.dart';
import 'package:xindong/routes/tab_moments/view/xindong_dongtai_list_view_cell_media.dart';

class XinDongDongTaiListViewCell extends StatelessWidget {
  final XinDongDongTaiClass model;
  final bool isDetails;
  final bool isSpace;

  final Function(XinDongDongTaiClass model) onDelete; //删除回调
  final Function(bool result) commentCallback; //评论回调
  const XinDongDongTaiListViewCell({
    Key? key,
    required this.model,
    required this.isDetails,
    this.isSpace = false,
    required this.onDelete,
    required this.commentCallback,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    const paddingLeft = kPaddingValue + 50 + 10;
    return GestureDetector(
      onTap: () {
        if (isDetails) {
          return;
        }
        XinDongPageSingleton.instance.pushYeMian(XinDongDongTaiDetailsYeMian(
          model: model,
          isSpace: isSpace,
          deleteSuccessCallback: onDelete,
        ));
      },
      behavior: HitTestBehavior.opaque,
      child: Container(
        color: Colors.transparent,
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            XinDongDongTaiListViewCellHeader(model: model, onDelete: onDelete),
            XinDongDongTaiListViewCellMedia(model: model, paddingLeft: paddingLeft, cellContext: context),
            Container(
              height: 30,
              alignment: Alignment.bottomLeft,
              padding: const EdgeInsets.only(left: paddingLeft, right: kPaddingValue),
              child: Text(
                "${model.addtime} 浏览${model.visit}次 ${model.fabu_city}",
                style: const TextStyle(color: DZColors.contentColor, fontSize: 12),
              ),
            ),
            XinDongDongTaiListViewCellFooter(model: model, paddingLeft: paddingLeft, commentCallback: commentCallback),
          ],
        ),
      ),
    );
  }
}
